package Player
{
	import flash.events.*;
	import flash.media.Sound;
	import flash.media.SoundChannel;
	import flash.media.SoundTransform;
	import flash.net.URLRequest;
	import flash.utils.Timer;
	import flash.utils.flash_proxy;
	
	import mx.collections.ArrayCollection;
	import mx.containers.Panel;
	import mx.controls.Button;
	import mx.managers.ICursorManager;
	
	public class MP3Player extends EventDispatcher
	{
		/*
		private var song:SoundChannel;
		
		private var request:URLRequest;
		
		private var paused:Boolean = true;
		
		private var stopped:Boolean = false;
		
		private var position:Number;
		
		private var soundFactory:Sound;
		
		private var mute:Boolean = false;
		
		public function MP3Player()
		{
			super();
		}     
		
		
		
		// Play MP3 at specified index in songURLs array.
		public function onStartSong(event:PlayerEvent) : void
		{
			if (song)
				song.stop();
			stopped = false;
			paused = false;
			position = 0;
			var request:URLRequest = new URLRequest(event.path);
			soundFactory = new Sound();
			soundFactory.addEventListener(Event.ID3, id3Handler);
			soundFactory.load(request);
			song = soundFactory.play();
			
			var e:PlayerEvent = new PlayerEvent(PlayerEvent.STARTSONG);
			e.data = soundFactory;
			dispatchEvent(e);
			song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
		}
		
		private function id3Handler(event:Event):void
		{
			dispatchEvent(new Event("songNameChanged"));
		}     
		
		private function soundCompleteHandler(event:Event):void
		{
			
		}     
		
		public function muteSound() : void
		{
			if (!mute)
				song.soundTransform = new SoundTransform(0, 0);
			else
				song.soundTransform = new SoundTransform(1, 1);
			
			mute = !mute;
		}
		
		public function volumeSound() : void
		{
			
		}
		
		public function pause():void
		{
			if (paused)
			{
				paused = false;
				if (soundFactory != null)
				{
					song = soundFactory.play(position);
					song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
				}
			}
			else
			{
				paused = true;
				position = song.position;
				song.stop();
			}
		}     
		
		// Stop current song
		public function stop():void
		{
			stopped = true;
			song.stop();
			position = 0;
		}     
		
//*/
	}
}